package entity_model.json.serializers;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import entity_model.Relationship;

import java.lang.reflect.Type;

/**
* Created by nuno-rafael-figueiredo on 13-05-2014.
*/
public class RoleSerializer implements JsonSerializer<Relationship.Role> {

    @Override
    public JsonElement serialize(Relationship.Role src, Type typeOfSrc, JsonSerializationContext context) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("cardinality", src.getCardinality().toString());
        jsonObject.addProperty("entity", src.getEntity().getName());
        jsonObject.addProperty("name", src.getName());
        return jsonObject;
    }
}
